<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>帖子分类管理</title>
    <link rel="stylesheet" href="__LAY__/css/layui.css" media="all">
    <link rel="stylesheet" href="__CSS__/main.css" media="all">
    <link rel="stylesheet" href="__FONT__/css/font-awesome.min.css" media="all" />
</head>
<body>
<div class="right_body">
    <div class="right_content_top">
        <blockquote class="layui-elem-quote">
            <a href="{:url('forum/addNoteCate')}" class="layui-btn">添加</a>
            <!--<button class="layui-btn  layui-btn-normal">搜索</button>-->
        </blockquote>
    </div>
    <div style="text-align: center;">
        <div class="layui-inline">
            <table id="demo" lay-filter="test"></table>
        </div>
    </div>
</div>
</body>
<script type="text/javascript" src="__JS__/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="__LAY__/layui.js"></script>
<script type="text/javascript" src="__JS__/index.js"></script>
<script src="https://cdn.bootcss.com/limonte-sweetalert2/7.21.1/sweetalert2.all.js"></script>
<script>
    function initTable(){
        layui.use('table', function(){
            var table = layui.table;
            //第一个实例
            table.render({
                elem: '#demo'
                ,height: 500
                ,url: "{:url('forum/noteCate')}" //数据接口
                ,page: true //开启分页
                ,cols: [[ //表头
                    {field: 'id', title: 'ID',width:60,unresize:true,align:'center'}
                    ,{field: 'name', title: '分类名称',unresize:true,align:'center'}
                    ,{field: 'stateStr', title: '状态',unresize:true,align:'center'}
                    ,{field: 'sort', title: '排序',unresize:true,align:'center'}
                    ,{field: 'operate', title: '操作',unresize:true,align:'center'}
                ]]
            });

        });
    }
    $(document).ready(function () {
        //调用函数，初始化表格
        initTable();
    });
    function delNoteCate(id){
        swal({
            title: "确定删除吗？",
            text: "删除后将无法恢复",
            type: "warning",
            showCancelButton: true,
            confirmButtonColor: "#DD6B55",
            confirmButtonText: "确定删除！",
            cancelButtonText: "取消删除！",
            closeOnConfirm: false,
            closeOnCancel: false

        })
            .then(function(isConfirm){
                if(isConfirm.value) {
                    $.getJSON("{:url('forum/delNoteCate')}", {'id' : id}, function(res){
                        if(1 == res.code){
                            swal("干得漂亮！", res.msg,"success");
                            initTable();
                        }else if(111 == res.code){
                            window.location.reload();
                        }else{
                            layer.alert(res.msg, {title: '友情提示', icon: 2});
                        }
                    });
                } else {
                    swal("取消！", "感谢您没有把我删除奥","error");
                }
            });
    }





</script>
</html>